package com.controller;

import com.pojo.Client;
import com.pojo.User;
import com.service.ClientService;
import com.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.Errors;
import org.springframework.validation.ObjectError;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.List;

@Controller("clientControllerImpl")
@RequestMapping("/client")
public class ClientControllerImpl implements ClientController{
    @Autowired
    private ClientService clientService;

    @RequestMapping("/add")
    public String add(Client client) {

        clientService.add(client);
        return "redirect:/seccess.jsp";
    }

    @RequestMapping("/update")
    public String update(){
        return "...";
    }

    @RequestMapping("/select")
    public String select(Client client, Model model){
        System.out.println(2222);
        client=clientService.select(client);
        System.out.println(2222);
        model.addAttribute("client", client);
        return "success";
    }

    @RequestMapping("/query")
    public String query(Model model) {

        //System.out.println(1111);
        List<Client> list = clientService.query();
        //System.out.println(list);
        model.addAttribute("list", list);
        //System.out.println(222);

        return "success";
    }
}
